<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!--#include file="lib/error_write.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<link href="lib/yaml/central_draft.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript">
	$(function() {
		$("input[name='post']").click(function(){
			if($(this).attr("checked")){
				$(this).next().next().removeAttr("disabled")
			}else{
				$(this).next().next().attr("disabled","disabled")
			}
		});
	});
</script>	
</head>

<body>
<%
call CheckRights(0,15)
If (CStr(Request.form("mm_add")) <> "") Then
	user=trim(SafeRequest("user",0))
	name=trim(SafeRequest("name",0))
	post=request.form("post")
	active=request.form("active")
	if active="" then active=false
	if user="" then error_write "1","没有填写[用户名]"
	if name="" then error_write "2","没有填写[姓名]"
	if post="" then error_write "3","没有选择[岗位]"
	flag=""
	post=""
	for i=1 to request.form("post").count
		post=post&request.form("post")(i)&","
		flag=flag&request.form("flag")(i)&","
	next
	post=left(post,len(post)-1)
	flag=left(flag,len(flag)-1)
	

	'response.write post&flag
	'response.end
	pws=user&"12345678"
	'response.write username
	'response.Write password
	'response.write email
	'response.write sql

	Set rs = Server.CreateObject("ADODB.Recordset")
	sql = "SELECT *  FROM yh where [user]='"&user&"'"
	rs.Open sql,conn,1,1
	if not rs.eof then error_write "4","[用户名]重复"
	rs.close
	set rs=nothing
	
	set cmd=Server.CreateObject("ADODB.Command")
	cmd.ActiveConnection = conn
	sql="insert into yh([user],[pass],flag,[name],post,active) values('"&user&"','"&pws&"','"&flag&"','"&name&"','"&post&"',"&active&")"
	'response.Write(sql)
	cmd.CommandText = sql
	cmd.Execute
	cmd.ActiveConnection.Close
	view_url="manage_user.asp"
	response.Redirect(view_url)
	conn.close
	set conn=nothing

end if

%>
<div  class="page_margins">
  <div class="page">
    <div id="nav">

      <div class="hlist">
        <ul>
          <li><a href="manage_user.asp">用户信息管理</a></li>
          <li><a href="add_user.asp">添加用户</a></li>
        </ul>
      </div>

    </div>
		<div id="main">
			<div id="col1">

<form name="form1" method="post" action="#" class="yform" role="application">
	<fieldset>
		<legend>基本资料</legend>
		<div class="type-text">
			<label for="user">用户名*</label>
			<input name="user" id="user" type="text" size="20" />
		</div>
		<div class="type-text">
			<label for="name">姓名*</label>
			<input name="name" id="name" type="text" size="10" />
		</div>
	</fieldset>
	<fieldset>
		<legend>岗位和权限*</legend>
		<div class="type-check type-select">
			<input name="post" id="post0" type="checkbox" value="0" />
			<label for="post0">用户权限</label>
			<select name="flag" disabled="disabled">
				<option value="1">查询</option>
				<option value="2">查询、查看</option>
				<option value="3">查询、查看、添加</option>
				<option value="4">查询、查看、添加、编辑</option>
				<option value="5">查询、查看、添加、编辑、删除</option>
				<option value="15">管理员</option>
			</select>
		</div>
		<div class="type-check type-select">
			<input name="post" id="post1" type="checkbox" value="1" />
			<label for="post1">船务</label>
			<select name="flag" disabled="disabled">
				<option value="1">查询</option>
				<option value="2">查询、查看</option>
				<option value="3">查询、查看、添加</option>
				<option value="4">查询、查看、添加、编辑</option>
				<option value="5">查询、查看、添加、编辑、删除</option>
				<option value="15">管理员</option>
			</select>
		</div>
		<div class="type-check type-select">
			<input name="post" id="post2" type="checkbox" value="2" />
			<label for="post2">车队</label>
			<select name="flag" disabled="disabled">
				<option value="1">查询</option>
				<option value="2">查询、查看</option>
				<option value="3">查询、查看、添加</option>
				<option value="4">查询、查看、添加、编辑</option>
				<option value="5">查询、查看、添加、编辑、删除</option>
				<option value="15">管理员</option>
			</select>
		</div>
		<div class="type-check type-select">
			<input name="post" id="post3" type="checkbox" value="3" />
			<label for="post3">商务</label>
			<select name="flag" disabled="disabled">
				<option value="1">查询</option>
				<option value="2">查询、查看</option>
				<option value="3">查询、查看、添加</option>
				<option value="4">查询、查看、添加、编辑</option>
				<option value="5">查询、查看、添加、编辑、删除</option>
				<option value="15">管理员</option>
			</select>
		</div>
		<div class="type-check type-select">
			<input name="post" id="post4" type="checkbox" value="4" />
			<label for="post4">财务</label>
			<select name="flag" disabled="disabled">
				<option value="1">查询</option>
				<option value="2">查询、查看</option>
				<option value="3">查询、查看、添加</option>
				<option value="4">查询、查看、添加、编辑</option>
				<option value="5">查询、查看、添加、编辑、删除</option>
				<option value="15">管理员</option>
			</select>
		</div>
	</fieldset>
	<fieldset>
		<legend>激活</legend>
		<div class="type-check">
			<input name="active" id="active" type="checkbox" value="true" />
			<label for="active">激活用户</label>
		</div>
	</fieldset>
	<div  class="type-button">
	<input type="submit" name="Submit" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="reset" name="Reset" value="重置" />
	<input type="hidden" name="mm_add" value="true" />
	</div>
</form>
			</div>
		</div>
	</div>
</div>
</body>
</html>

